import Vue from 'vue'

/*iE 兼容*/
import 'babel-polyfill';

import App from './App'
import router from '@/router'
import store from '@/store'
/* 使用路由守卫对router全局权限拦截, */
/*import '../config/guard'*/
import 'normalize.css/normalize.css';
import 'nprogress/nprogress.css';
import '@/assets/style/element-reset.less';
import '@/assets/style/reset.less';
import '@/assets/style/icon.less';
/* 导入全局配置 */
import '../config/config'
/* 引入localStrong */
import storage from '@/config/storage'
/* Element */
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './utils/directive'


import qs from 'qs'

//引入过滤器
import {
  filters
} from '@/filters'
filters.forEach(item => {
  Vue.filter(item.name, item.filter)
})

//echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

Vue.use(ElementUI);

//计算屏幕大小
Vue.prototype.$deviceW = function () {
  var docEl = document.documentElement,
    clientWidth = docEl.clientWidth;
  docEl.style.fontSize = 20 * (clientWidth / 1920) + 'px';
}

Vue.prototype.host = host
Vue.prototype.maphost = maphost
//时间差8小时转
Date.prototype.dateFtt = function (date1,fmt) {
  if(date1==null){
    return ''
  } //author: meizz

  var fmt = fmt||"yyyy-MM-dd hh:mm:ss";
  // console.log(data)
  var date = new Date(date1);
  var o = {
    "M+": date.getMonth() + 1, //月份
    "d+": date.getDate(), //日
    "h+": date.getHours(), //小时
    "m+": date.getMinutes(), //分
    "s+": date.getSeconds(), //秒
    "q+": Math.floor((date.getMonth() + 3) / 3), //季度
    S: date.getMilliseconds(), //毫秒
    T: "T" //时间分隔符T
  };
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(
      RegExp.$1,
      (date.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(
        RegExp.$1,
        RegExp.$1.length == 1 ?
        o[k] :
        ("00" + o[k]).substr(("" + o[k]).length)
      );
  return fmt;
}

Date.prototype.dateFtt1 = function (date1) { //author: meizz

  // console.log(data)
  var date = date1.slice(5,date1.length);
  return date.replace('T',' ').replace('Z','')
}

String.prototype.hideidCard = function (value) {
  if(value ==null){
    return ''
  }
  var str1 = value.slice(0, 4);

  var str2 = '';

  var str3 = value.slice(14);

  if (value.length == 15) {

    str2 = '******';

  } else {

    str2 = '**********';

  }

  return str1 + str2 + str3;

}
String.prototype.getbirthday=function(value){
  if(value==null){
    return ''
  }
  if(value.length==18){
    var str1=value.slice(6, 10);
    var str2=value.slice(10,12)
    var str3=value.slice(12,14)
    return str1+'-'+str2+'-'+str3
  }else{
    return ''
  }

}

String.prototype.hideName=function(value){
  if(value==null){
    return ''
  }
  if(value.length>=3){
    return value.substr(0,1)+'*'+value.substr(value.length-1,1)
  }else{
    return value.substr(0,1)+'*'
  }

}
/* Vue.prototype.$whiteList = whiteList; */
Vue.prototype.$storage = storage;
Vue.prototype.$qs = qs;
Vue.prototype.$bus = new Vue();
Vue.config.productionTip = false
/*  Vue全局使用Router  */
Vue.use(router)

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
